package acn.spring.backend;

import java.util.List;

import org.hibernate.SessionFactory;

import acn.spring.domain.Item;

public class ItemDaoHibernateWithoutDaoSupport implements ItemDao {
	
	private SessionFactory sessionFactory;

	@Override
	public List<Item> getAllItems() {
		@SuppressWarnings("unchecked")
		List<Item> items = sessionFactory.getCurrentSession().createQuery("from Item").list();
		return items;
	}

	@Override
	public Item addItem(Item item) {
		sessionFactory.getCurrentSession().save(item);
		return null;
	}

	@Override
	public Item getItemWithId(int itemId) {
		return null;
	}

	@Override
	public void deleteItem(int id) {
	}

	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

}
